import uuid
from typing import Any

import pytest

from recruit.domain.models.resume_info import (
    BaseResumeInfo,
    ResumeInfoCreate,
    ResumeInfoResult, ResumeInfoUpdate,
)
from tests.domain.models.utils import check_attr_model, check_json_schema


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'residence': 'Residence',
                'name': 'Name',
                'patronymic': 'Patronymic',
                'surname': 'Surname'
            },
            ('residence', 'name', 'patronymic', 'surname')
    )]
)
def test_resume_info_base(data: dict[str, str], keys: tuple[str, ...]) -> None:
    check_attr_model(BaseResumeInfo, data)
    check_json_schema(BaseResumeInfo, keys)
    check_attr_model(BaseResumeInfo, {}, tuple(data))
    check_json_schema(BaseResumeInfo, keys)


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'residence': 'Residence',
                'name': 'Name',
                'patronymic': 'Patronymic',
                'surname': 'Surname'
            },
            ('residence', 'name', 'patronymic', 'surname')
    )]
)
def test_resume_info_create(
        data: dict[str, str],
        keys: tuple[str, ...]
) -> None:
    assert issubclass(ResumeInfoCreate, BaseResumeInfo)
    check_attr_model(ResumeInfoCreate, data)
    check_json_schema(BaseResumeInfo, keys)
    del data['residence']
    check_attr_model(ResumeInfoCreate, data, ('residence',))
    check_json_schema(BaseResumeInfo, keys)


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'id': uuid.uuid4(),
                'residence': 'Residence',
                'name': 'Name',
                'patronymic': 'Patronymic',
                'surname': 'Surname'
            },
            ('id', 'residence', 'name', 'patronymic', 'surname')
    )]
)
def test_resume_info_result(
        data: dict[str, Any],
        keys: tuple[str, ...]
) -> None:
    assert issubclass(ResumeInfoResult, BaseResumeInfo)
    check_attr_model(ResumeInfoResult, data)
    check_json_schema(ResumeInfoResult, keys)
    del data['residence']
    check_attr_model(ResumeInfoResult, data, ('residence',))
    check_json_schema(ResumeInfoResult, keys)


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'residence': 'Residence',
                'name': 'Name',
                'patronymic': 'Patronymic',
                'surname': 'Surname'
            },
            ('residence', 'name', 'patronymic', 'surname')
    )]
)
def test_resume_info_update(
        data: dict[str, Any],
        keys: tuple[str, ...]
) -> None:
    assert issubclass(ResumeInfoUpdate, BaseResumeInfo)
    check_attr_model(ResumeInfoUpdate, data)
    check_json_schema(ResumeInfoUpdate, keys)
    check_attr_model(ResumeInfoUpdate, {}, empty_keys=tuple(data))
    check_json_schema(ResumeInfoUpdate, keys)
